package dome2;

public class Text {
    public static void main(String[] args) {

    }
    public static void main3(String[] args) {
        char[] ch = new char[]{'a', 'b', 'c'};
        String s1 = new String(ch); // s1对象并不在常量池中
        String s2 = "abc"; // "abc" 在常量池中存在了，s2创建时直接用常量池中"abc"的引用
        System.out.println(s1 == s2);
    }
    public static void main2(String[] args) {
        String s1 = new String("hello");
        String s2 = new String("hello");
        String s3 = s1;
        System.out.println(s1==s2);//false
        System.out.println(s1==s3);//true
    }
    public static void main1(String[] args) {
        String s1 = "hello";
        String s2 = "hello";
        System.out.println(s1 == s2); // true
        String s3 = new String("hello");
        System.out.println(s1 == s3); // false;

    }
}
